package bieche.eric.util;

import java.io.Serializable;
import java.util.ArrayList;
import bieche.eric.util.TribbleRound;

public class TribblePlayer implements Serializable
{
   
   /**
    * 
    */
   private static final long serialVersionUID = -2925413853807518195L;

   private String name;
   private ArrayList<TribbleRound> rounds;
   private boolean selected;

   public TribblePlayer(String name)
   {
      this.name = name;
      this.selected = false;
      this.rounds = new ArrayList<TribbleRound>();

      for( int index = 0; index < TribbleRound.MAXROUNDS; ++index )
      {
         rounds.add(new bieche.eric.util.TribbleRound());
      }
   }// End of Constructor

   public void scorePoints(int type, int amount, int roundNumber)
   {
      rounds.get(roundNumber - 1).scorePoints(type, amount);
   }

   public int getTotalScore()
   { 
      int sum = 0;
      for(TribbleRound tr : rounds) sum += tr.getTotalScore();
      return sum;
   }

   public String getName() { return name; }
   public ArrayList<TribbleRound> getRounds() { return rounds; }

   public boolean isSelected() { return this.selected; }
   public boolean getSelected() { return this.selected; }
   public void setSelected(boolean selected) { this.selected = selected; }

   public TribbleRound getRoundOne()   { return rounds.get( 0 ); }
   public TribbleRound getRoundTwo()   { return rounds.get( 1 ); }
   public TribbleRound getRoundThree() { return rounds.get( 2 ); }
   public TribbleRound getRoundFour()  { return rounds.get( 3 ); }
   public TribbleRound getRoundFive()  { return rounds.get( 4 ); }

   @Override
   public String toString()
   {
      return "TribblePlayer [name=" + name + ", rounds=" + rounds
            + ", selected=" + selected + "]";
   }
   
}//End of Class
